export HOME=HOME_PATH
echo -e ${white}"====="${green}白狐-Script${white}"====="${background}
echo -e ${green}请选择您的BOT下载源${background}
echo -e  ${green} 1. ${cyan}Gitee [大陆服务器推荐]${background}
echo -e  ${green} 2. ${cyan}Github[国外服务器推荐]${background}
echo "========================="
echo -en ${green}请输入您的选项: ${background};read num
case ${num} in 
  1)
    GitMirror="https://gitee.com"
    ;;
  2)
    GitMirror="https://github.com"
    ;;
  *)
    echo -e ${red}输入错误${background}
    exit
    ;;
esac
install_Bot(){
  if [ "${Bot_Name}" == "Miao-Yunzai" ]
  then
    Git=${GitMirror}/yoimiya-kokomi/Miao-Yunzai.git
  elif [ "${Bot_Name}" == "TRSS-Yunzai" ]
  then
     Git=${GitMirror}/TimeRainStarSky/Yunzai.git
  fi
  echo -e ${cyan}正在克隆${Bot_Name}${background}
  if ! git clone --depth=1 ${Git} $HOME/${Bot_Name};then
    echo -e ${red}克隆失败${background}
    exit
  fi
}
install_Miao_Plugin(){
  echo -e ${cyan}正在克隆喵喵插件${background}
  Git=${GitMirror}/yoimiya-kokomi/miao-plugin.git
  if ! git clone --depth=1 ${Git} $HOME/${Bot_Name}/plugins/miao-plugin;then
    echo -e ${red}克隆失败${background}
    exit
  fi
}
install_Genshin(){
  echo -e ${cyan}正在克隆原神组件${background}
  Git=${GitMirror}/TimeRainStarSky/Yunzai-genshin
  if ! git clone --depth=1 ${Git} $HOME/${Bot_Name}/plugins/genshin;then
    echo -e ${red}克隆失败${background}
    exit
  fi
}
if [ "${Bot_Name}" == "Miao-Yunzai" ];then
    if [ ! -e $HOME/${Bot_Name}/package.json ];then
        install_Bot
    fi
    if [ ! -e $HOME/${Bot_Name}/plugins/miao-plugin/index.js ];then
        install_Miao_Plugin
    fi
    if [ ! -d $HOME/${Bot_Name}/node_modules ];then
        cd $HOME/${Bot_Name}
        bash Package.sh 
    fi
elif [ "${Bot_Name}" == "TRSS-Yunzai" ];then
    if [ ! -e $HOME/${Bot_Name}/package.json ];then
        install_Bot
    fi
    if [ ! -e $HOME/${Bot_Name}/plugins/miao-plugin/index.js ];then
        install_Miao_Plugin
    fi
    if [ ! -e $HOME/${Bot_Name}/plugins/genshin/index.js ];then
        install_Genshin
    fi
    if [ ! -d $HOME/${Bot_Name}/node_modules ];then
        cd $HOME/${Bot_Name}
        bash Package.sh
    fi
fi